/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.yitun.chat.yitunservermanagecore.general.manage.server.controller;

import cn.yitun.chat.yituncommonmessage.result.ResultMessage;
import cn.yitun.chat.yitunservercommonlib.dataentity.data.server.ServerData;
import cn.yitun.chat.yitunservermanagecore.general.manage.server.service.ServerService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 服务器
 * @author chenyitun
 * @date 2020-06-19
 */
@Controller
@RequestMapping("/api/chat")
public class ServerController {

	@Resource
	private ServerService serverService;

	/**
	 * @author yitun
	 * @date 2017-11-26 09:12:37
	 * @param request
	 * @return
	 */
	@CrossOrigin
	@ResponseBody
	@RequestMapping(method = RequestMethod.POST, value = "/server/getAddress")
	public Object address(HttpServletRequest request) {
		ResultMessage rm = new ResultMessage();
		rm.addWarning("001", "新版服务器已不支持当前客户端，请升级到新版客户端！");
		return rm;
	}

	@CrossOrigin
	@ResponseBody
	@RequestMapping(method = RequestMethod.POST, value = "/server/addressList")
	public Object serverAddressList(HttpServletRequest request) {
		ResultMessage rm = new ResultMessage();
		List<ServerData> list = serverService.getServerDataList();
		rm.bodyPut("list", list);
		return rm;
	}

}
